<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateUserCloseFriendLogTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('user_close_friend_log', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('user_id')->default(0)->comment('用户ID');
            $table->unsignedInteger('frd_user_id')->default(0)->comment('密友ID');
            $table->double('close_value', 5, 2)->default(0.0)->comment('增加（减少）的亲密度');
            $table->tinyInteger('from')->default(0)->comment('来源');
            $table->tinyInteger('flag')->default(1)->comment('1有效0无效');
            $table->timestamps();
            $table->index(['user_id', 'frd_user_id'], 'user_chat');
            $table->index(['frd_user_id', 'user_id'], 'chat_user');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('user_close_friend_log');
    }
}
